import axios from 'axios';
import qs from 'qs';

// 创建订单
export const createOrder = (params) => {
  return axios.post('t_order', params, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
};

// 获取订单列表
export const getOrderList = (params) => {
  return axios.get('t_order/user/'+ params.userId, params, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
};

// 获取订单详情
export const getOrderById = (params) => {
  return axios.post('OrdersController/getOrderById', params, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
};

// 更新订单状态
export const updateOrderStatus = (params) => {
  return axios.post('OrdersController/updateOrderStatus', params, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
};

// 提交订单评价
export const createEvaluation = (params) => {
  return axios.post('review/add', params, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
};

// 获取订单评价列表
export const getEvaluationsByOrderId = (orderId) => {
  return axios.get(`review/order/${orderId}`, {
    headers: {
      'Content-Type': 'application/json'
    }
  });
};